package com.qf.controller;

import com.fasterxml.jackson.databind.ser.Serializers;
import com.qf.pojo.entity.Goods;
import com.qf.pojo.entity.GoodsClassify;
import com.qf.pojo.entity.StoreInfo;
import com.qf.pojo.req.ClassifyListReq;
import com.qf.pojo.resp.BaseResp;
import com.qf.service.FlowerService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/flower")
@Api(tags = "药店,超市,水果,鲜花绿植分类公用接口")
public class FlowerController {

    @Autowired
    FlowerService flowerService;

    //一级分类查询查询所有商家,商品进行封装,以及三级分类进行封装
    @ApiOperation("点击一级分类,进入得到所有商铺的数据和三级分类的数据,商铺里面封装了商品数据(classifyList对象的id必传)")
    @PostMapping("/findAll")
    public BaseResp findAll(@RequestBody ClassifyListReq classifyListReq){
        return  flowerService.findAll(classifyListReq);
    }
    //通过店铺id,找到物品分类id
    @ApiOperation("传入店铺id,找到店铺内部分类信息(storeInfo对象的id必传)")
    @PostMapping("/findClassify")
    public BaseResp findClassify(@RequestBody StoreInfo storeInfo){
            return  flowerService.findClassify(storeInfo.getId());
    }
        //通过商品分类id找到商品
        @ApiOperation("点击分类传入分类id拿到商品数据(goodsClassify对象的id必传)")
    @PostMapping("/findGoodsByClassifyId")
    public BaseResp findGoodsByClassifyId(@RequestBody GoodsClassify goodsClassify){
            return  flowerService.findGoodsByClassifyId(goodsClassify.getId());
    }
    //通过花的三级分类名称找到商品
    @ApiOperation("传入花的三级分类的字符串(String类型的flowerName),该接口只适用于鲜花类")
    @PostMapping("/findGoodsByName")
    public BaseResp findGoodsByName(String flowerName){
        return  flowerService.findByFlowerName(flowerName);
    }


    //通过活动找到店铺,以及商品等详细信息
    @ApiOperation("满减优惠等活动等,传入string 类型字符串(String类型的freeName),该接口只适用于鲜花类")
    @PostMapping("/findByFree")
    public BaseResp findByFree(String freeName){
        System.out.println(freeName);
        return  flowerService.findByFree(freeName);
    }
}
